#include "ppm.h"
#include "stdio.h"

uint16_t PPM_Sample_Cnt = 0;
uint8_t PPM_Chn_Max = 8;
uint32_t PPM_Time = 0;
uint16_t PPM_Okay = 0;
uint16_t PPM_Databuf[8] = {0};


void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
    if(GPIO_Pin==GPIO_PIN_8)
    {
        PPM_Time = TIM2 ->CNT;
        TIM2 -> CNT = 0;
        if (PPM_Okay == 1)
        {
            PPM_Sample_Cnt++;
            PPM_Databuf[PPM_Sample_Cnt - 1] = PPM_Time;
            if (PPM_Sample_Cnt >= PPM_Chn_Max)
                PPM_Okay = 0;
        }
        if (PPM_Time >= 2050)
        {
            PPM_Okay = 1;
            PPM_Sample_Cnt = 0;
        }
    }
}

